package com.ptl.bp.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.ptl.bp.dto.*;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Type;

import javax.persistence.*;
import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "battery_passports")
@TableName(value = "battery_passports", autoResultMap = true)
@Schema(description = "电池护照主实体")
public class BatteryPassport extends BaseEntity {

    // @Id
    // @GeneratedValue(strategy = GenerationType.IDENTITY)
    // @Comment("主键")
    // @Schema(description = "主键ID", example = "1")
    // @TableId(type = IdType.AUTO) // Mybatis主键生成策略, 使用数据库的自增
    // private Long id;

    @Enumerated(EnumType.STRING)
    @Comment("电池护照状态")
    @Schema(description = "电池护照状态", example = "DRAFT")
    private PassportDocumentStatus documentStatus = PassportDocumentStatus.DRAFT;

    @Type(type = "json")
    @Column(columnDefinition = "json")
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Schema(description = "通用产品信息")
    private BatteryGeneralProductInfo generalInfo;

    @Type(type = "json")
    @Column(columnDefinition = "json")
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Schema(description = "符号、标签、符合性声明文档")
    private BatteryLabelsEntity labelsConformity;

    @Type(type = "json")
    @Column(columnDefinition = "json")
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Schema(description = "材料组成")
    private BatteryMaterialComposition materialComposition;

    @Type(type = "json")
    @Column(columnDefinition = "json")
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Schema(description = "碳排放信息")
    private BatteryCarbonFootprint carbonFootprint;

    @Type(type = "json")
    @Column(columnDefinition = "json")
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Schema(description = "性能数据")
    private BatteryPerformanceAndDurability performanceData;

    @Type(type = "json")
    @Column(columnDefinition = "json")
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Schema(description = "循环性信息")
    private BatteryCircularityEntity circularityInfo;

    @Type(type = "json")
    @Column(columnDefinition = "json")
    @TableField(typeHandler = JacksonTypeHandler.class)
    @Schema(description = "供应链信息")
    private BatterySupplyChainDueDiligence supplyChain;

    @Deprecated
    @Column(updatable = false)
    @Schema(description = "创建时间", example = "2025-01-01 10:10:10")
    private LocalDateTime createdAt = LocalDateTime.now();

    @Deprecated
    @Schema(description = "更新时间", example = "2025-01-01 10:10:10")
    private LocalDateTime updatedAt = LocalDateTime.now();

    public enum BatteryCategory {
        lmt, ev, industrial, stationary
    }

    public enum BatteryStatus {
        Original, Repurposed, Reused, Remanufactured, Waste
    }

    // 新增电池护照状态枚举
    public enum PassportDocumentStatus {
        @Schema(description = "草稿")
        DRAFT,

        @Schema(description = "已发布")
        PUBLISHED
    }
}